layui.config({
	base : "js/"
}).use(['form','layer'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;
	//video背景
	$(window).resize(function(){
		if($(".video-player").width() > $(window).width()){
			$(".video-player").css({"height":$(window).height(),"width":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}else{
			$(".video-player").css({"width":$(window).width(),"height":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}
	}).resize();
	
	//登录按钮事件
	form.on("submit(login)",function(data){
		//window.location.href = "../../index.html";
		//return false;
            $.post(
                '/user_login',
                data.field,
                function (result) {
                    if (result.success && result.verifyCode) {
                        sessionStorage.setItem("User_Login",JSON.stringify(result.admin));
                        window.location.href = "../../index.html";
                    }
                    else if(result.success==true && result.verifyCode==false){
                        $("#loginmsg").text('');
                        $("#loginmsg").append('验证码错误，登陆失败');
                    }
                    else {
                        //location.reload();
                        $("#loginmsg").text('');
                        $("#loginmsg").append('账号或密码错误，登陆失败');
                    }
                }
            );
            return false;
        });
	})
//获得验证码
function reCode(){
    $("#code").attr("src","/getcode"+"?"+Math.random());
};

